function trim(s, ch) {
	ch = ch || '\\s';
	return s.replace(new RegExp('^['+ch+']+|['+ch+']+$', 'g'), '');
}

function extend() {
	var src = arguments[0] || {};
	for (var i=1; i<arguments.length ; i++ ){
		for (var k in arguments[i]){
			src[k] = arguments[i][k];
		}
	}
	return src;
}

function isIE() {
	if (typeof isIE.result == "undefined"){
		var client_pc = navigator.userAgent.toLowerCase();
		isIE.result = (client_pc.indexOf("msie") != -1) && (client_pc.indexOf("opera") == -1)
	}
	return isIE.result ;
}

function map(arr, callback) {
	if (arr.length){
		for (var i=0; i<arr.length ; i++ )
			arr[i] = callback(arr[i], i);
	} else {
		for (var i in arr)
			arr[i] = callback(arr[i], i);
	}
	return arr;
}

function grep(arr, callback) {
	var r = [];
	if (arr.length){
		for (var i=0; i<arr.length ; i++ )
			if (callback(arr[i], i))	r.push(arr[i]);
	} else {
		for (var i in arr)
			if (callback(arr[i], i))	r.push(arr[i]);
	}
	return r;
}

function inArray(value, arr) {
	return grep(arr, function(v){
		return v==value;
	}).length;
}

function merge(arr1, arr2) {
	map(arr2, function(o){
		if (!inArray(o, arr1)){
			arr1.push(o);
		}
	});
	return arr1;
}